perm filename XJP[S1,ALS] blob sn#452636 filedate 1979-07-05 generic text, type T, neo UTF8
UXJP :			(* peg 05jul79 *)
    begin
    (*XJP compiles into
	       SKP if too small to A
	       SKP if not too big to B
	    A: JUMP to default
	    B: JUMP to wherever(index)	*)

    if TOP <> BOT then
	ERROR (WXJP_WITHOUT_SINGLETON_STACK);
    if not IS_INTEGER[TYP] then
	ERROR (WWRONG_INSTR_DATATYPE);
    if not (TYP = STK[TOP].DTYPE) then
	ERROR (WINSTR_TYPE_NOT_DATUM_TYPE);

    LABNUM1 := LABELNUMBER(NAM1);
    LABNUM2 := LABELNUMBER(NAM2);
    COERCE_DATUM (TOP, TYPUJ);		(**** Implicit coersion.*)
    if IS_CONSTANT(TOP) then
	begin
	IMM_OPERAND (OPND, STK[TOP].FPA.MEMADR.DSPLMT);
	EXTENDED_REGDISP_OPERAND
	    (OPND1, S1RPC,  I1 - STK[TOP].FPA.MEMADR.DSPLMT)
			    (*Looks funny but it is compatible with
				the negate-and-shift fixup which
				must be done in the case of a
				variable index.*)
	end
    else
	begin
	GET_SHORT_OPERAND (OPND, TOP);
	OPND1 := OPND;
	OPND1.X := 1;
	OPND1.XW.V := 1;
	OPND1.XW.S := DALIGNSHIFT;
	OPND1.XW.REG := S1RPC;
	OPND.XW.DISP := -I1;
	end;

    IMM_OPERAND(OPND2, I1);
    SKIPSMALL := NEWINSTREC;
    EMITSOP (XSKP_LSS_S, 0, OPND, OPND2, nil);
    IMM_OPERAND(OPND2, I2);
    SKIPNOTBIG := NEWINSTREC;
    EMITSOP (XSKP_LEQ_S, 0, OPND, OPND2, nil);
    JUMPDEFAULT := NEWINSTREC;
    EMITJOP (XJMPA, 0, UNUSED_OP, ZERO_OP, nil);
    JUMPINDEXED := NEWINSTREC;
    EMITJOP (XJMPA, 0, UNUSED_OP, OPND1, nil);

    FIXSOP (SKIPSMALL, JUMPDEFAULT);
    FIXSOP (SKIPNOTBIG, JUMPINDEXED);
    JUMP_TO_LABEL_RECORD_OR_FIX (JUMPDEFAULT, LABNUM2);
    ADD_CODEPTR_TO_CODELIST (NEG_SHIFT_FIXLIST, JUMPINDEXED);
	(*All OPND2s on this fixup list will have the displacement
	    in the extended word negated and arithmetically shifted
	    to make it a doubleword index.*)
    JUMP_TO_TABLE_RECORD_OR_FIX (JUMPINDEXED, LABNUM1);

    FREEDATUMREGS (TOP);
    POPTOP;
    end (*UXJP*);